package ee.reliability.tool.ui;

import info.monitorenter.gui.chart.IAxis;
import info.monitorenter.gui.chart.LabeledValue;
import info.monitorenter.gui.chart.axis.scalepolicy.AxisScalePolicyManualTicks;

import java.awt.Graphics;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class AxisScalePolicyFixedTicks extends AxisScalePolicyManualTicks {

	private final List<Integer> pointList = new ArrayList<>();

	@Override
	public List<LabeledValue> getScaleValues(Graphics arg0, IAxis<?> arg1) {
		List<LabeledValue> scaleValues = new LinkedList<>();
		for (int i = 0; i < pointList.size(); i++) {
			Integer point = pointList.get(i);
			LabeledValue labeledValue = new LabeledValue();
			labeledValue.setLabel(Integer.toString(point));
			labeledValue.setMajorTick(true);
			labeledValue.setValue((double)i/(pointList.size()-1));
			scaleValues.add(labeledValue);
		}
		return scaleValues;
	}

	public void addPoint(int value) {
		pointList.add(value);
	}

	public void clearPoints() {
		pointList.clear();
	}
}
